import {
	createStore
} from 'vuex'

const store = createStore({
	// 定义全局变量
	state: {
		hasLogin: false,
		isUniverifyLogin: false,
		userInfo: null
	},
	// set 
	mutations: {
		login(state, user) {
			state.hasLogin = true;
			state.userInfo = user;
		},
		logout(state) {
			state.hasLogin = false
			state.userInfo = null
		}
	},
	// get
	getters: {
		isLogin(state) {
			return state.hasLogin
		},
		userInfo(state){
			return state.userInfo
		}
	},
	// 定义全局动作
	actions: {
		// lazy loading openid
		getUserOpenId: async function({
			commit,
			state
		}) {
			return ""
		}
	}
})

export default store